import time
from multiprocessing import Pool


def run(x, y):
    print("===========================")
    time.sleep(5)
    print(x + y)
    return "结束"


if __name__ == '__main__':
    list1 = [[1, 2], [2, 2], [3, 2], [4, 2]]
    # 获取当前时间戳
    t1 = time.time()
    res_list = []
    # 创建进程池
    pool = Pool(4)
    for i, j in list1:
        # # 同步操作
        # ret = pool.apply(run,(i,j))
        # 异步执行
        res = pool.apply_async(run, (i, j))
        res_list.append(res)
    pool.close()
    pool.join()
    for i in res_list:
        print(i.get())
    t2 = time.time()
    print(t2 - t1)
